package com.example.service;


import com.example.dao.User_rolesMapper;
import com.example.dao.UsersMapper;
import com.example.pojo.User_roles;
import com.example.pojo.Users;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.*;

@Service
public class LoginAdmin {

    @Resource
    UsersMapper usersMapper;

    @Resource
    User_rolesMapper user_rolesMapper;

    public boolean loginAdmin(String username,String password){

        Users users = usersMapper.login(new Users(username,password));
        User_roles user_roles =user_rolesMapper.selectRoleName(username);

        if(users != null){

            if(user_roles.getRole_name().equals("boss")){
                return true;
            }

        }
        return false;
    }

    public HashSet showAll(){
        List<Users> list = usersMapper.selectAll();
        HashSet<String> hashSet = usersMapper.selectAllAddr();
        Map<String,List<Users>> map = new HashMap<String,List<Users>>();
        List<Users> users = new ArrayList<Users>();
        for (Users i : list) {
           i.getProvince();
        }

        return hashSet;
    }

}
